<template lang="html">
  <section class="components-property-coupon_header">
    <i class="icon-code">
      <span>code</span>
    </i>
    <input type="text" placeholder="请输入优惠券兑换码" v-model.trim="couponCode">
    <button @click="emitExchange">立即兑换</button>
  </section>
</template>

<script>
import utils from '@/lib/utils'
export default {
  name: 'CouponHeader',
  props: {
    clearEmitter:{
      type: Number
    }
  },
  data(){
    return {
      couponCode: ''
    }
  },
  watch: {
    clearEmitter(){
      this.couponCode = ''
    }
  },
  methods: {
    emitExchange(){
      if(this.couponCode !== ''){
        this.$emit('eExchageCoupon', this.couponCode)
      } else {
        utils.toast('请输入优惠券兑换码')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../../css/config";
$input-height: 86px;
.components-property-coupon_header{
  position: relative;
  width: 100%;
  height: $property-header-height;
  background:#f1f1f6 ;
  padding: 29px 40px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  .icon-code{
    position: absolute;
    top: $input-height/2 + 29px;
    transform: translateY(-50%);
    left: 25px + 40px;
    display: block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 100%;
    background-color: #818181;
    font-size: 24px;
    color: #fff;
    font-style: normal;
    white-space: nowrap;
    overflow: hidden;
    span{
      position: absolute;
      z-index: 0;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      font-family: sans-serif;
      letter-spacing: 1Px;
    }
  }
  input{
    width: 100%;
    height: $input-height;
    border-radius: 25px;
    font-size: 24px;
    border: 2px solid #818181;
    text-indent: 100px;
  }
  button{
    width: 261px;
    height: 65px;
    color:#fff;
    font-size: 24px;
    background: $common-red;
    border-radius: 25px;
  }
}
</style>
